#根据用户输入的问题检索相关文档。

from vector_store import VectorStore

class Retriever:
    def __init__(self, embedding_client, vector_store:VectorStore):
        self.embedding_client = embedding_client
        self.vector_store = vector_store

    def retrieve(self, user_input):
        # 向量搜索
        results = self.vector_store.search(user_input, 1)
        relation_docs = results['documents']
        #print("-----------relation_docs----------")
        #print(relation_docs)
        # 展平二维列表
        flattened_docs = [doc for sublist in relation_docs for doc in sublist]
        # 使用 join 方法连接字符串
        docs = "\n\n".join(flattened_docs)
        #print(docs)
        return docs